<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>百度ECHarts</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/layui.css" rel="stylesheet">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="/js/layui-v2.6.6/layui/css/layui.css">
    <link rel="stylesheet" href="/css/main/index.css">
</head>
<style>
.gray-bg {
    margin: 0;
    box-sizing: border-box;
    padding: 0 15px;
    padding-right: 10px;
}
.adminHeader {
    padding: 12px 15px !important;
    margin: 16px 0 0 0;
}
.card{
    cursor: pointer;
}
.wrapper{
    padding: 0;
}
</style>
<body class="gray-bg">
<div class="row  border-bottom white-bg dashboard-header adminHeader">
    <div class="col-sm-12">
        <img src="../../../img/adminhi.png" alt="hi"
             style="width: 24px;height: 20px;vertical-align: middle;margin-right: 5px">
        <p style="display: inline-block;vertical-align: middle;">欢迎 <span th:text="${name}" style="font-size: 17px"></span>
        </p>
    </div>
</div>

<div class="wrapper animated fadeInRight container" style="margin-top: 10px">
    <div class="rows" id="cards"></div>
    <div id="info" class="rows" style="margin-top: 10px;margin-bottom: 10px">
    </div>
    <div class="row">
        <div class="col-sm-12" style="padding: 0">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>正在进行的竞赛</h5>
                    <div class="ibox-tools">
                    </div>
                </div>

                <table id="templet" lay-filter="templet"></table>

            </div>
        </div>
    </div>

</div>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/layui/layui.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0"></script>
<!--<script type="text/javascript" src="/js/contabs.js"></script>-->
<script>
    var roleNames = $("#roleNames").text();
    if (roleNames.indexOf("超级用户角色") > -1) {
        $("#t1").show();
        $("#t2").hide();
        $("#t3").hide();
    } else if (roleNames.indexOf("考核站点") > -1) {
        $("#t1").hide();
        $("#t2").show();
        $("#t3").hide();
    } else {
        $("#t1").hide();
        $("#t2").hide();
        $("#t3").show();
    }

    function skipHtml(value) {
        let baseUrl = window.location.origin
        const menu = window.parent.$('.J_menuItem');//父页面的方法
        for (let i = 0; i < menu.length; i++) {
            if (menu[i].href === `${baseUrl}${value}`) {
                menu[i].click()
            }
        }
    }

    $(function () {
        $.ajax({
            url: '/earning',
            type: 'POST',
            success: function (r) {
                if (r.code == 0) {
                    var info = `<ul>
                                    <li class="card" onclick="skipHtml('/jzweb/examinationBatch?type=3')">
                                        <div class="titles content" style="margin-left: 0">
                                            <h2>创建竞赛</h2>
                                            <p>快速创建并发布竞赛</p>
                                            <img  src="../../../img/zhix (2).png" alt="创建竞赛">
                                        </div>
                                        <img  id="competition" src="../../../img/js (2).png" alt="快速创建并发布竞赛">
                                    </li>
                                    <li class="card" onclick="skipHtml('/jzweb/itemBank')">
                                        <div class="titles content" style="margin-left: 0">
                                            <h2>试题导入</h2>
                                            <p>试题信息统一管理</p>
                                            <img   src="../../../img/zhix3 (2).png" alt="试题导入">
                                        </div>
                                        <img id="testQuestions" src="../../../img/st (2).png" alt="快速创建并发布竞赛">
                                    </li>
                                    <li class="card" onclick="skipHtml('/jzweb/stuSignUpCom?types=3')">
                                        <div class="titles content" style="margin-left: 0">
                                            <h2>选手管理</h2>
                                            <p>选手信息统一管理</p>
                                            <img  id="xsskipHtml" src="../../../img/zhix2 (2).png" alt="选手管理">
                                        </div>
                                        <img id="player" src="../../../img/xs (2).png" alt="选手信息统一管理">
                                    </li>
                        </ul> `
                    $('#info').html(info);
                }
            }
        })

        $.ajax({
            url: '/getRecharge',
            type: 'POST',
            success: function (r) {
                if (r.code == 0) {
                    let templates = `
                     <ul>
                        <li>
                            <img src="../../../img/zjs (2).png" alt="总竞赛数">
                            <div class="titles">
                                <p>总竞赛数</p>
                                <h1 id="incomeCompetition" style="font-size: 35px"></h1>
                            </div>
                        </li>
                        <li>
                            <img src="../../../img/zst (2).png" alt="总试题数">
                            <div class="titles">
                                <p>总试题数</p>
                                <h1 id="topicCount" style="font-size: 35px"></h1>
                            </div>
                        </li>
                        <li>
                            <img src="../../../img/zks (4).png" alt="总考生数">
                            <div class="titles">
                                <p>总考生数</p>
                                <h1 id="headcount" style="font-size: 35px"></h1>
                            </div>
                        </li>
                        <li>
                            <img src="../../../img/zks (3).png" alt="总参加数">
                            <div class="titles">
                                <p>总参加数</p>
                                <h1 id="totality" style="font-size: 35px"></h1>
                            </div>
                        </li>
                        <li>
                            <img src="../../../img/zrcjs (2).png" alt="昨日参加数">
                            <div class="titles">
                                <p>昨日参加数</p>
                                <h1 id="yesterdaySum" style="font-size: 35px"></h1>
                            </div>
                        </li>
                        <li>
                            <img src="../../../img/jyz (2).png" alt="近一周参加数">
                            <div class="titles">
                                <p>近一周参加数</p>
                                <h1 id="weeksSum" style="font-size: 35px"></h1>
                            </div>
                        </li>
                    </ul>
                    `
                    $('#cards').html(templates)
                    let data = r.data
                    $('#incomeCompetition').html(data.incomeCompetition)
                    $('#topicCount').html(data.topicCount)
                    $('#headcount').html(data.headcount)
                    $('#totality').html(data.totality)
                    $('#yesterdaySum').html(data.yesterdaySum)
                    $('#weeksSum').html(data.weeksSum)
                }
            }
        })



        layui.use('table', function () {
            var table = layui.table;
            //第一个实例
            table.render({
                elem: '#templet'
                , url: '/jzApi/examinations/selExaminationComAll' //数据接口
                , cols: [[ //表头
                    {field: 'name', title: '竞赛名称'}
                    , {
                        field: 'startTime', title: '竞赛时间', templet: function (d) {
                            if (d) {
                                return d.startTime + ' ~ ' + d.endTime;
                            }
                        }
                    }
                    , {
                        field: 'type', title: '竞赛方式', templet: function (d) {
                            if (d) {
                                return '<span>' + d.type + '</span>'
                            }
                        }
                    }
                    , {field: 'num', title: '竞赛总人数'}
                ]]
            });

        });

    })

</script>
</body>

</html>
